package com.example.tsproject.Controller;

import com.example.tsproject.entity.PageBean;
import com.example.tsproject.entity.Result;
import com.example.tsproject.entity.TeacherPosts;
import com.example.tsproject.service.TeacherPostsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/teacherPosts")
public class TeacherPostsController {
    @Autowired
    private TeacherPostsService teacherPostsService;

    // 分页查询
    @GetMapping
    public Result<PageBean<TeacherPosts>> list(
            Integer pageNum,
            Integer pageSize,
            @RequestParam(required = false) String name, //根据作者姓名查询
            @RequestParam(required = false) String content, //根据文章内容查询
            @RequestParam(required = false) LocalDateTime startTime,
            @RequestParam(required = false) LocalDateTime endTime //根据发布时间查询
    ) {
        PageBean<TeacherPosts> pageBean = teacherPostsService.list(pageNum, pageSize, name, content, startTime, endTime);
        return Result.success(pageBean);
    }
}
